package com.ps.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ps.property.ResponseVO;
import com.ps.property.TUserMessage;
import com.ps.service.LeaveWordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author gt
 * @类说明：
 * @date 2020/10/27 19:21
 */
@Api(tags = "用户留言接口")
@Controller
@Validated
@Slf4j
public class ProvideLeaveWordController {
    @Autowired
    LeaveWordService leaveWordService;

    @ApiOperation(value = "新增用户留言信息接口",notes = "新增用户留言信息接口，新增用户留言")
    @PostMapping("/leaveWordAdd-provide")
    @ResponseBody
    ResponseVO leaveWordAdd(@Valid @RequestBody TUserMessage tUserMessage) {
        return ResponseVO.success(leaveWordService.leaveWordAdd(tUserMessage));
    }

    @ApiOperation(value = "分页查询用户留言信息接口",notes = "分页查询用户留言信息接口，分页查询用户留言")
    @ApiImplicitParams({@ApiImplicitParam(name = "currentPage", value = "当前页数", required = true),@ApiImplicitParam(name = "pageSize", value = "每页行数", required = true)})
    @GetMapping("/leaveWordQuery-provide")
    @ResponseBody
    ResponseVO leaveWordQuery(@RequestParam("currentPage") int currentPage, @RequestParam("pageSize") int pageSize) {
        return ResponseVO.success(leaveWordService.leaveWordQuery(currentPage,pageSize));
    }

    @ApiOperation(value = "根据联系人分页查询用户留言信息接口",notes = "根据联系人分页查询用户留言信息接口，根据联系人分页查询用户留言")
    @ApiImplicitParams({@ApiImplicitParam(name = "currentPage", value = "当前页数", required = true),@ApiImplicitParam(name = "pageSize", value = "每页行数", required = true),@ApiImplicitParam(name = "contacts", value = "联系人", required = true)})
    @GetMapping("/leaveWordQueryByContacts-provide")
    @ResponseBody
    ResponseVO leaveWordQueryByContacts(@RequestParam("currentPage") int currentPage, @RequestParam("pageSize") int pageSize, @RequestParam("contacts") String contacts) {
        return ResponseVO.success(leaveWordService.leaveWordQuery(currentPage,pageSize));
    }

    @ApiOperation(value = "根据用户留言id修改用户留言信息接口",notes = "修改用户留言信息接口，修改用户留言")
    @ApiImplicitParam(name = "messageId",value = "用户留言ID",required = true)
    @PostMapping("/leaveWordUpdate-provide")
    @ResponseBody
    ResponseVO leaveWordUpdate(@Valid @RequestBody TUserMessage tUserMessage) {
        return ResponseVO.success(leaveWordService.leaveWordUpdate(tUserMessage));
    }

    @ApiOperation(value = "根据用户留言id查询用户留言信息接口",notes = "查询用户留言信息接口，查询用户留言")
    @ApiImplicitParam(name = "messageId",value = "用户留言ID",required = true)
    @GetMapping("/leaveWordQueryById-provide/{messageId}")
    @ResponseBody
    ResponseVO leaveWordQueryById(@PathVariable int messageId) {
        return ResponseVO.success(leaveWordService.leaveWordQueryById(messageId));
    }
}
